﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using System.Security.Principal;
using Rhino.Mocks;

namespace DatingSoonMVC2008Tests
{
    public static class MVCHelpers
    {
        public static HttpContextBase MockIPrincipalForHttpContext(MockRepository mocks, HttpContextBase mockHttpContext, bool isAuthenticated)
        {
            IPrincipal user = mocks.CreateMock<IPrincipal>();
            IIdentity identity = mocks.CreateMock<IIdentity>();
            SetupResult.For(identity.IsAuthenticated).Return(isAuthenticated);
            SetupResult.For(user.Identity).Return(identity);
            SetupResult.For(mockHttpContext.User).Return(user);

            return mockHttpContext;
        }

        public static HttpContextBase CreateMockHttpContext(MockRepository mocks)
        {
            HttpContextBase mockHttpContext = mocks.CreateMock<HttpContextBase>();
            HttpResponseBase stubHttpResponse = mocks.CreateMock<HttpResponseBase>();
            SetupResult.For(mockHttpContext.Response).Return(stubHttpResponse);
            stubHttpResponse.Redirect(null);
            return mockHttpContext;
        }
    }
}
